package com.example.lotterysystem.service.mq;

import com.example.lotterysystem.common.config.DirectRabbitConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * 功能描述:
 *
 * @author Lenovo
 * @date 2025/2/5
 */
@Slf4j
@Component
@RabbitListener(queues = DirectRabbitConfig.DLX_QUEUE_NAME)
public class DlxReceiver {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    @RabbitHandler
    public void process(Map<String, String> message) {
        log.info("开始处理异常消息");
        rabbitTemplate.convertAndSend(DirectRabbitConfig.EXCHANGE_NAME, DirectRabbitConfig.ROUTING, message);
    }
}
